package com.acme.bankapp.service.bank.commands;

import java.util.HashMap;
import java.util.Map;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.service.bank.BankReporter;

public class BankConsoleStatisticsCommandFactory {
	static public Map<String,BankConsoleStatisticsCommand> Create () {
		Map<String,BankConsoleStatisticsCommand> cmdMap = new HashMap<String, BankConsoleStatisticsCommand>();
		
		cmdMap.put("getnumcust", new BankConsoleStatisticsCommand() {
			@Override
			public String getCommandDescription() {
				return "get # of clients";
			}
			
			@Override
			public String execCommand(BankReporter br, Bank bank) {
				return "Number of clients is " + br.getNbOfCustomers(bank);
			}
		});
		
		cmdMap.put("getnumacc", new BankConsoleStatisticsCommand() {
			@Override
			public String getCommandDescription() {
				return "get # of accounts";
			}
			
			@Override
			public String execCommand(BankReporter br, Bank bank) {
				return "Number of accounts is " + br.getNbOfAccounts(bank);
			}
		});
		
		cmdMap.put("getaccsorted", new BankConsoleStatisticsCommand() {
			@Override
			public String getCommandDescription() {
				return "get list of accounts sorted by balance";
			}
			
			@Override
			public String execCommand(BankReporter br, Bank bank) {
				return br.getAccountsSortedBySum(bank).toString();
			}
		});
		
		cmdMap.put("getcred", new BankConsoleStatisticsCommand() {
			@Override
			public String getCommandDescription() {
				return "get bank's credit";
			}
			
			@Override
			public String execCommand(BankReporter br, Bank bank) {
				return "Bank's credit is " + br.getBankCredit(bank);
			}
		});
		
		return cmdMap;
	}
}
